-
-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: summarizable associations #3428
base: main
Are you sure you want to change the base?
feature: summarizable associations #3428
Conversation
Code Climate has analyzed commit b3f357b and detected 0 issues on this pull request. View more on Code Climate. |
0036e9c
to
26835c0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've provided some code snippets with suggestions (not tested) on how we might apply the scope from the association field
query = resource.authorization&.apply_policy related_records | ||
|
||
Avo::ExecutionContext.new(target: resource.search_query, query: query).handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
query = resource.authorization&.apply_policy related_records | |
Avo::ExecutionContext.new(target: resource.search_query, query: query).handle | |
related_records |
def related_records | ||
relation_class = BaseResource.get_model_by_name(params[:via_relation_class]) | ||
parent = relation_class.find(params[:via_record_id]) | ||
|
||
association_name = BaseResource.valid_association_name(parent, resource.model_key) | ||
|
||
parent.send(association_name) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def related_records | |
relation_class = BaseResource.get_model_by_name(params[:via_relation_class]) | |
parent = relation_class.find(params[:via_record_id]) | |
association_name = BaseResource.valid_association_name(parent, resource.model_key) | |
parent.send(association_name) | |
end | |
def related_records | |
relation_class = BaseResource.get_model_by_name(params[:via_relation_class]) | |
parent = relation_class.find(params[:via_record_id]) | |
association_name = BaseResource.valid_association_name(parent, resource.model_key) | |
parent_resource = ... | |
association_field = ... | |
query = resource.authorization.apply_policy parent.send(association_name) | |
Avo::ExecutionContext.new( | |
target: association_field.scope, | |
query: query, | |
parent: parent, | |
resource: resource, | |
parent_resource: parent_resource | |
).handle | |
end |
Description
Fixes #2993
Checklist:
Screenshots & recording